package com.xge.business

import android.content.Context
import android.widget.Toast
import com.alibaba.android.arouter.utils.TextUtils
import com.lxj.xpopup.core.CenterPopupView
import com.xge.business.databinding.DialogAddContentBinding

class DialogAddContent(context: Context) : CenterPopupView(context) {

    var onSubmitClick: ((String) -> Unit)? = null

    private lateinit var binding: DialogAddContentBinding

    override fun getImplLayoutId(): Int {
        return R.layout.dialog_add_content
    }

    override fun onCreate() {
        super.onCreate()
        binding = DialogAddContentBinding.bind(popupImplView)

        binding.tvCancel.setOnClickListener { dismiss() }
        binding.clSubmit.setOnClickListener {
            val content = binding.edContent.text.toString()
            if(TextUtils.isEmpty(content)){
                Toast.makeText(context,"内容不能为空",Toast.LENGTH_SHORT).show()
            }else{
                onSubmitClick?.invoke(content)
            }
        }
    }
}